package appapi.service.impl;

import appapi.Request.record.AiExceptionPageReq;
import appapi.Request.record.AiExceptionReq;
import appapi.Vo.brider.AlarmVO;
import appapi.dto.bridge.AiExceptionDto;
import appapi.entity.bridge.AiExceptionEntity;
import appapi.mapper.AiExceptionMapper;
import appapi.service.AiExceptionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 请求对象
 *
 * @author luocheng
 * @version 1.0
 * @date 2023/09/18 14:36
 */
@Service
public class AiExceptionServiceImpl extends ServiceImpl<AiExceptionMapper, AiExceptionEntity> implements AiExceptionService {

    @Resource
    private AiExceptionMapper aiExceptionMapper;
    /**
     * 分页查询记录列表
     *
     * @return
     */
    @Override
    public  IPage<AiExceptionDto> getAiExceptionByPage(AiExceptionPageReq req){
        PageHelper.startPage(req.getCurrPage(), req.getPageSize());
        List<AiExceptionDto> rtnList = aiExceptionMapper.selectAiExceptionListPage(req);
        PageInfo<AiExceptionDto> info = new PageInfo<>(rtnList);
        IPage<AiExceptionDto> pageInfo = new Page<>();
        if(rtnList.size() > 0){
            pageInfo.setRecords(rtnList);
            pageInfo.setSize(req.getPageSize());
            pageInfo.setTotal(info.getTotal());
            pageInfo.setCurrent(req.getCurrPage());
        }
        return pageInfo;
    }

    /**
     * 获取记录列表
     * @param req
     * @return
     */
    @Override
    public List<AiExceptionDto> getAiExceptionList(AiExceptionReq req)
    {
        return aiExceptionMapper.selectAiExceptionList(req);
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @Override
    public  AiExceptionDto getAiExceptionModel(Long id)
    {
        return aiExceptionMapper.selectAiException(id);
    }
}
